package com.lujianfei.recyclerview.recyclerview_vertical;

import android.os.Bundle;

import com.lujianfei.recyclerview.R;
import com.lujianfei.recyclerview.adapter.RecyclerAdapter;
import com.lujianfei.recyclerview.adapter.RecyclerScrollHideSearchAdapter;
import com.lujianfei.recyclerview.entity.ListItem;

import java.util.ArrayList;
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class ScrollHideSearchActivity extends AppCompatActivity {

    RecyclerView recyclerview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scroll_hide_search);
        recyclerview = findViewById(R.id.recyclerview);
        /** 设置列表布局方式 */
        LinearLayoutManager layoutManager= new LinearLayoutManager(this);
        recyclerview.setLayoutManager(layoutManager);
        List<ListItem> listItems = genData();
        RecyclerScrollHideSearchAdapter recyclerAdapter = new RecyclerScrollHideSearchAdapter(listItems);
        recyclerview.setAdapter(recyclerAdapter);
    }

    private List<ListItem> genData() {
        List<ListItem> listItems = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            listItems.add(new ListItem("Title "+i,"Summary "+i));
        }
        return listItems;
    }

}
